Yap

Yap, Yet Another Previewer, is a simple text-editor which provides the ability to interactively execute the documents as PostScript programs.  Yap demonstrates:

· Execution of random PostScript code in a separate window server context
· Caching drawing for fast scrolling purposes
· Multi-window documents loaded from nib files containing ScrollViews with subclass of  Text
· Pasting PostScript as text
· A simple Find panel

YapOutput.m and YapWrap.psw contain the code which creates a separate context that is focused on a window belonging to the application's main context and send PostScript down to this second context for execution. This second context is kept around as long as no errors occur; however, in case of errors a new one is created.

YapDocument.m shows the YapDocument class which manages the documents. The source code for YapDocument demonstrates, among other things, how to read a .nib file over and over again to create multiple document windows.
 
If your application needs to import EPS files, then its probably best to stick to the NXEPSImageRep class (or NXImage, which uses NXEPSImageRep to manage its EPS representations) rather than using the code in YapOutput.m. NXEPSImageRep uses a separate context to execute EPS files in a manner similar to Yap.